package com.unb.transportebsb;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.nutiteq.log.Log;

public class OpcoesParadaActivity extends Activity {
    Button btProxOnibus;
    Button btLinhas;
    Button btAvaliarServico;
    double longitude, latitude;
    String local;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.opcoes_parada);

        Bundle extras = this.getIntent().getExtras();
        longitude = extras.getDouble("longitude");
        Log.debug("Longitude: " + longitude);
        latitude = extras.getDouble("latitude");
        Log.debug("Latitude: " + latitude);
        local = extras.getString("local");
        Log.debug("Local: " + local);

        btProxOnibus = (Button) findViewById(R.id.btProxOnibus);
        btLinhas = (Button) findViewById(R.id.btLinhas);
        btAvaliarServico = (Button) findViewById(R.id.btAvaliarServico);

        btProxOnibus.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent i = new Intent(OpcoesParadaActivity.this, ProximosOnibusActivity.class);
                i.putExtra("longitude", longitude);
                i.putExtra("latitude", latitude);
                startActivity(i);

            }
        });

        btLinhas.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent i = new Intent(OpcoesParadaActivity.this, ListarLinhasActivity.class);
                i.putExtra("longitude", longitude);
                i.putExtra("latitude", latitude);
                startActivity(i);

            }
        });

        btAvaliarServico.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent i = new Intent(OpcoesParadaActivity.this, AvaliacaoServicoActivity.class);
                i.putExtra("longitude", longitude);
                i.putExtra("latitude", latitude);
                // AsyncTask<String, Void, List<String[]>> at = new
                // GeoCodingTask()
                // .execute("http://nominatim.openstreetmap.org/reverse?format=json&lat="
                // + latitude + "&lon=" + longitude);
                // try {
                // i.putExtra("local", at.get().get(0)[1] + ", " +
                // at.get().get(0)[2] + ", " + at.get().get(0)[3]);
                // } catch (InterruptedException e) {
                // Log.error("InterruptException: " + e.getMessage());
                // } catch (ExecutionException e) {
                // Log.error("ExecutionException: " + e.getMessage());
                // }
                startActivity(i);

            }
        });
    }

}
